package to52.android.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
 * Gestion database android
 * @author david
 *
 */
public class Database extends SQLiteOpenHelper {
	
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "to52";

	public Database(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS ecarome_user;");
		db.execSQL("DROP TABLE IF EXISTS ecarome_medecin_patient;");
		db.execSQL("DROP TABLE IF EXISTS ecarome_sensor_values;");
		db.execSQL("" +
				"CREATE TABLE ecarome_users ( " +
				"id INT(11), " +
				"username TEXT, " +
				"password TEXT, " +
				"type INT(1), " +
				"profil_nom TEXT, " +
				"profil_prenom TEXT, " +
				"profil_age TEXT, " +
				"profil_taille DOUBLE, " +
				"profil_photo_url TEXT);");
		db.execSQL("" +
				"CREATE TABLE ecarome_medecin_patient ( " +
				"id INT(11), " +
				"medecin INT(11), " +
				"patient INT(11));");
		db.execSQL("" +
				"CREATE TABLE ecarome_sensor_values ( " +
				"id INT(11), " +
				"patient INT(11), " +
				"sensor INT(11), " +
				"value DOUBLE, " +
				"time BIGINT(20));");
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		
	}

}
